<template>
  <div class="type">
    <list class="typeList">
      <cell class="typeListItem" v-for="(item, index) in longList" :key="index" @click="addClassFun(item)" :class="[type === item.value ? 'active' : '']">
        <text class="text" :class="[type === item.value ? 'active' : '']">{{item.name}}</text>
      </cell>
    </list>
  </div>
</template>
<script>
import store from '@/store/dmHome'

export default {
  name: 'type',
  data () {
    return {
      longList: [
        { name: '农户', value: '1'},
        { name: '村委会公益服务场所', value: '2'},
        { name: '设施农业', value: '3'}
      ]
    }
  },
  methods: {
    addClassFun (item) {
      store.commit('changeType', item.value)
      store.dispatch('getAzddList', this)
      this.$emit('closeList')
    }
  },
  computed: {
    type () {
      return store.state.type
    }
  }
}
</script>
<style scoped>
.type{
  width: 750px;
  background-color: rgba(0, 0, 0, 0.4);
  flex: 1;
}
.typeList{
  width: 750px;
}
.typeListItem{
  width: 750px;
  height: 100px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-left: 20.8px;
  border-bottom-color: #eee;
  border-bottom-style: solid;
  border-bottom-width: 1px;
  background-color: white;
}
.text{
  font-size: 29.1px;
  font-family:PingFangSC-Regular;
  color:rgba(102,102,102,1);
}
.active{
  color: #fff;
  background-color: rgba(62,175,252,1);
}
</style>